home *** CD-ROM | disk | FTP | other *** search
- unit Dialog_1;
-
- {File name: Dialog_1.Pas }
- {Function: Handle a dialog}
- {History: 10/6/89 Original by Prototyper. }
- { }
-
-
- interface
-
- uses
- Utilities;
-
-
-
- procedure D_Dialog_1;
-
- implementation
-
- const {These are the item numbers for controls in the Dialog}
- I_x = 1;
- I_Picture1 = 2;
- var
- ExitDialog: boolean; {Flag used to exit the Dialog}
- DoubleClick: boolean; {Flag to say that a double click on a list happened}
- MyPt: Point; {Current list selection point}
- MyErr: OSErr; {OS error returned}
-
- {===========================================================}
-
- function MyFilter (theDialog: DialogPtr; var theEvent: EventRecord; var itemHit: integer): boolean;
- var
- tempRect: Rect;
-
- begin
- MyFilter := FALSE;
- if (theEvent.what = MouseDown) then{Only do on a mouse click}
- begin
- MyPt := theEvent.where;{Get the point where the mouse was clicked}
- GlobalToLocal(MyPt); {Convert global to local}
-
-
- end;
- end;
-
- {===========================================================}
-
-
- procedure D_Dialog_1;
- var
- GetSelection: DialogPtr;{Pointer to this dialog}
- tempRect: Rect; {Temporary rectangle}
- DType: Integer; {Type of dialog item}
- Index: Integer; {For looping}
- DItem: Handle; {Handle to the dialog item}
- CItem, CTempItem: controlhandle;{Control handle}
- sTemp: Str255; {Get text entered, temp holding}
- itemHit: Integer; {Get selection}
- temp: Integer; {Get selection, temp holding}
- dataBounds: Rect; {Rect to setup the list}
- cSize: Point; {Pointer to a cell in a list}
- Icon_Handle: Handle; {Temp handle to read an Icon into}
- NewMouse: Point; {Mouse location during tracking Icon presses}
- InIcon: boolean; {Flag to say pressed in an Icon}
- ThisEditText: TEHandle; {Handle to get the Dialogs TE record}
- TheDialogPtr: DialogPeek;{Pointer to Dialogs definition record, contains the TE record}
-
- {This is an update routine for non-controls in the dialog}
- {This is executed after the dialog is uncovered by an alert}
- procedure Refresh_Dialog; {Refresh the dialogs non-controls}
- var
- rTempRect: Rect; {Temp rectangle used for drawing}
-
- begin
- SetPort(GetSelection); {Point to our dialog window}
- end;
-
-
- begin {Start of dialog handler}
- GetSelection := GetNewDialog(1, nil, Pointer(-1));{Bring in the dialog resource}
- ShowWindow(GetSelection);{Open a dialog box}
- SelectWindow(GetSelection);{Lets see it}
- SetPort(GetSelection); {Prepare to add conditional text}
-
- TheDialogPtr := DialogPeek(GetSelection);{Get to the inner record}
- ThisEditText := TheDialogPtr^.textH;{Get to the TE record}
- HLock(Handle(ThisEditText));{Lock it for safety}
- ThisEditText^^.txSize := 12;{TE Point size}
- TextSize(12); {Window Point size}
- ThisEditText^^.txFont := systemFont;{TE Font ID}
- TextFont(systemFont); {Window Font ID}
- ThisEditText^^.txFont := 0;{TE Font ID}
- ThisEditText^^.fontAscent := 12;{Font ascent}
- ThisEditText^^.lineHeight := 12 + 3 + 1;{Font ascent + descent + leading}
- HUnLock(Handle(ThisEditText));{UnLock the handle when done}
-
-
- {Setup initial conditions}
- Refresh_Dialog; {Draw any Lists, popups, lines, or rectangles}
-
- ExitDialog := FALSE; {Do not exit dialog handle loop yet}
-
- repeat {Start of dialog handle loop}
- ModalDialog(nil, itemHit);{Wait until an item is hit}
- GetDItem(GetSelection, itemHit, DType, DItem, tempRect);{Get item information}
- CItem := Pointer(DItem);{Get the control handle}
-
- {Handle it real time}
- if (ItemHit = I_Picture1) then{Handle the Picture}
- begin
- end; {End for this item selected}
- Wait(10);
- ExitDialog := TRUE;{Exit the dialog}
-
- until ExitDialog; {Handle dialog items until exit selected}
-
- {Get results after dialog}
-
- DisposDialog(GetSelection);{Flush the dialog out of memory}
-
- end; {End of procedure}
-
- end. {End of unit}